﻿Imports WindowsApplication1.GoogleAnalyticsMailHandler

Public Class EmailViewer

    
    Public Sub New()
         ' This call is required by the designer.
        InitializeComponent()
    End Sub

    Private Sub EmailViewer_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        e.Cancel = True
        Me.Hide()
    End Sub

    Public Sub AddEmail(ByVal email As Email)
        ' Dim item As ListViewItem = New ListViewItem({email.Subject, email.FromContact, email.UtcDateTime.ToString())
        'item.Tag = email
        'ListView1.Items.Add(item)
    End Sub

    Public Sub AddEmails(ByVal emailsVar As List(Of Email))
        For Each e In emailsVar
            AddEmail(e)
        Next
    End Sub


    Private Sub ListView1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        If ListView1.SelectedItems.Count = 1 Then
            Dim selected As ListViewItem = ListView1.SelectedItems(0)
            Dim email As Email = selected.Tag
            If Not email Is Nothing Then
                EmailViewerControl1.SetEmail(email)
            End If

        End If
    End Sub
End Class